package com.control.qct.businesssteward.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.adapter.SelectGoodsAdapter;
import com.control.qct.businesssteward.base.BaseActivity;
import com.control.qct.businesssteward.model.OpenOrderModel;
import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/1 0001.
 */

public class SelectGoodsActivity extends BaseActivity {

    @BindView(R.id.rv_select_goods)
    RecyclerView mRvSelectGoods;
    @BindView(R.id.tv_sure)
    TextView mTvSure;

    private List<OpenOrderModel> mOpenOrderModels;
    private List<OpenOrderModel.DatasBean> mDatasBeanList;
    private SelectGoodsAdapter mSelectGoodsAdapter;

    public SelectGoodsActivity() {
        super(R.layout.activity_select_goods);
    }

    @Override
    protected void initView() {
        setLeftIcon(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        setTitle("选择赠品");
        mDatasBeanList = new ArrayList<>();
        mRvSelectGoods.setLayoutManager(new LinearLayoutManager(this));
        mSelectGoodsAdapter = new SelectGoodsAdapter(mDatasBeanList);
        mRvSelectGoods.setAdapter(mSelectGoodsAdapter);
        mSelectGoodsAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                mSelectGoodsAdapter.setPosition(position);
            }
        });
    }


    @OnClick(R.id.tv_sure)
    public void onClicked(View v) {
        switch (v.getId()) {
            case R.id.tv_sure:
                setResult(RESULT_OK);
                finish();
                break;
        }
    }
}
